home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Georgia Wildfire Prevention
/
Georgia Wildfire Prevention.iso
/
pc
/
media
/
dirs
/
BackUp
/
code.cst
/
00011_Script_testobj
< prev
next >
Wrap
Text File
|
2002-10-15
|
4KB
|
155 lines
property scores,curnum,totalnum,questions,correct,cscore,alarm,wait_amt,test,next_action
on new me
scores=[#pre:0,#post:0]
alarm=0
wait_amt=0
return(me)
end
on init me
global ctrlobj
curnum=0
questions=[:]
read_questions(me)
totalnum=questions.count
correct=0
c=ctrlobj.history.count
test=ctrlobj.history[c].aux
if test="post" then
wait_amt=180
else
wait_amt=0
end if
end
on read_questions me
x=1
correct=0
cscore=0
mem=member("question"&string(x))
repeat while mem.number>0
str=mem.text
qlist=[]
repeat with i=1 to str.lines.count
qlist.add(str.line[i])
end repeat
questions.addprop(x,qlist)
x=x+1
mem=member("question"&string(x))
end repeat
actoron(me)
end
on next_question me
alarm=0
correct=[]
c=count(questions)
r=random(c)
qorder=getpropat(questions,r)
qlist=questions[r]
questions.deleteat(r)
sendallsprites(#new_q_graphic,"q"&string(qorder))
repeat with i=1 to (qlist.count)
qstring=qlist[i]
if qstring.char[1]="!" then
qstring=qstring.char[2..qstring.length]
correct.add(i)
end if
sendallsprites(#update_question,qorder)
sendallsprites(#answer_text,i,qstring)
end repeat
curnum=curnum+1
sendallsprites(#resume_answers)
sendallsprites(#current_num,curnum,totalnum)
end
on answer_clicked me,n
sendallsprites(#pause_answers)
if correct.getpos(n)>0 then
cscore=cscore+1
end if
if questions.count=0 then
test_done(me)
else
alarm=the ticks+wait_amt
next_action="next_question(me)"
end if
if test="post" then
tloc=sendallsprites(#get_loc,correct[1])
x1=tloc[1]-30
y1=tloc[2]
sendallsprites(#move_arrow,point(x1,y1))
end if
end
on stepframe me
if alarm>0 then
if the ticks>alarm then
do(next_action)
end if
end if
end
on actoron me
g=getpos(the actorlist,me)
if g=0 then add(the actorlist,me)
end
on actoroff me
g=getpos(the actorlist,me)
if g<>0 then deleteat(the actorlist,g)
end
on test_done me
x=4
if test="pre" then
next_action="show_score(me)"
alarm=the ticks+(member("Pre2").duration/11.0)
puppetsound 1,"Pre2"
end if
if test="post" then
next_action="show_score(me)"
alarm=the ticks+(member("Post2").duration/11.0)
puppetsound 1,"Post2"
end if
end
on show_score me
actoroff(me)
member("FinalScore").text=string(cscore)
go frame "score"
next_action=sendsprite(11,#blink_on)
if test="pre" then
alarm=the ticks+member("Pre3").duration
puppetsound 1,"Pre3"
scores.pre=cscore
end if
if test="post" then
alarm=the ticks+member("Post3").duration
puppetsound 1,"Post3"
scores.post=cscore
save_scores(me)
end if
sendallsprites(#set_tag,"score")
end
on save_scores me
global ctrlobj
str=numtochar(13)&numtochar(10)&"-----------------"&numtochar(13)&numtochar(10)&"Name:"&ctrlobj.userinfo.fname&" "&ctrlobj.userinfo.lname&numtochar(13)&numtochar(10)&"Date/time:"&the date&" "&the time&numtochar(13)&numtochar(10)&"Address:"&ctrlobj.userinfo.address&numtochar(13)&numtochar(10)&"City/state:"&ctrlobj.userinfo.city&" "&ctrlobj.userinfo.state&" "&ctrlobj.userinfo.zip&numtochar(13)&numtochar(10)&"Pretest Score:"&string(scores.pre)&numtochar(13)&numtochar(10)&"Post Test:"&string(scores.post)&numtochar(13)&numtochar(10)
fname=basysfolder("desktop")&"wpscores.txt"
fobj=new(xtra "fileio")
if fileexists(fname)=0 then
fobj.openfile(fname,0)
str=readfile(fobj)&str
else
createfile(fobj,fname)
fobj.openfile(fname,0)
end if
setposition(fobj,0)
writestring(fobj,str)
closefile(fobj)
end